﻿using System;
using System.Configuration;
using Microsoft.Ajax.Utilities;

/* Copyright (c) 2010 CBaxter
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 
 * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
 * IN THE SOFTWARE. 
 */

namespace Xpedite.Minification.MsAjaxMinifier.Config
{
  internal interface IJavaScriptOptions
  {
    Boolean AllowEmbeddedAspNetBlocks { get; }
    Boolean CollapseToLiteral { get; }
    Boolean CombineDuplicateLiterals { get; }
    String DebugLookupList { get; }
    Boolean EvalLiteralExpressions { get; }
    EvalTreatment EvalTreatment { get; }
    Boolean IgnoreConditionalCompilation { get; }
    String IgnoreErrorList { get; }
    Int32 IndentSize { get; }
    Boolean InlineSafeStrings { get; }
    String KnownGlobalNamesList { get; }
    LocalRenaming LocalRenaming { get; }
    Boolean MacSafariQuirks { get; }
    Boolean ManualRenamesProperties { get; }
    Boolean MinifyCode { get; }
    String NoAutoRenameList { get; }
    OutputMode OutputMode { get; }
    String PreprocessorDefineList { get; }
    Boolean PreserveFunctionNames { get; }
    Boolean PreserveImportantComments { get; }
    Boolean RemoveFunctionExpressionNames { get; }
    Boolean RemoveUnneededCode { get; }
    String RenamePairs { get; }
    Boolean ReorderScopeDeclarations { get; }
    Boolean StripDebugStatements { get; }
  }

  internal class JavaScriptConfigElement : ConfigurationElement, IJavaScriptOptions
  {
    [ConfigurationProperty("allowEmbeddedAspNetBlocks", IsRequired = false, DefaultValue = false)]
    public Boolean AllowEmbeddedAspNetBlocks { get { return (Boolean)base["allowEmbeddedAspNetBlocks"]; } }

    [ConfigurationProperty("collapseToLiteral", IsRequired = false, DefaultValue = true)]
    public Boolean CollapseToLiteral { get { return (Boolean)base["collapseToLiteral"]; } }

    [ConfigurationProperty("combineDuplicateLiterals", IsRequired = false, DefaultValue = false)]
    public Boolean CombineDuplicateLiterals { get { return (Boolean)base["combineDuplicateLiterals"]; } }

    [ConfigurationProperty("debugLookupList", IsRequired = false, DefaultValue = "Debug,$Debug,WAssert,Msn.Debug,Web.Debug")]
    public String DebugLookupList { get { return (String)base["debugLookupList"]; } }

    [ConfigurationProperty("evalLiteralExpressions", IsRequired = false, DefaultValue = true)]
    public Boolean EvalLiteralExpressions { get { return (Boolean)base["evalLiteralExpressions"]; } }

    [ConfigurationProperty("evalTreatment", IsRequired = false, DefaultValue = "Ignore")]
    public EvalTreatment EvalTreatment { get { return (EvalTreatment)base["evalTreatment"]; } }

    [ConfigurationProperty("ignoreConditionalCompilation", IsRequired = false, DefaultValue = false)]
    public Boolean IgnoreConditionalCompilation { get { return (Boolean)base["ignoreConditionalCompilation"]; } }

    [ConfigurationProperty("ignoreErrorList", IsRequired = false, DefaultValue = "")]
    public String IgnoreErrorList { get { return (String)base["ignoreErrorList"]; } }

    [ConfigurationProperty("indentSize", IsRequired = false, DefaultValue = 4)]
    public Int32 IndentSize { get { return (Int32)base["indentSize"]; } }

    [ConfigurationProperty("inlineSafeStrings", IsRequired = false, DefaultValue = true)]
    public Boolean InlineSafeStrings { get { return (Boolean)base["inlineSafeStrings"]; } }

    [ConfigurationProperty("knownGlobalNamesList", IsRequired = false, DefaultValue = "")]
    public String KnownGlobalNamesList { get { return (String)base["knownGlobalNamesList"]; } }

    [ConfigurationProperty("localRenaming", IsRequired = false, DefaultValue = "CrunchAll")]
    public LocalRenaming LocalRenaming { get { return (LocalRenaming)base["localRenaming"]; } }

    [ConfigurationProperty("macSafariQuirks", IsRequired = false, DefaultValue = true)]
    public Boolean MacSafariQuirks { get { return (Boolean)base["macSafariQuirks"]; } }

    [ConfigurationProperty("manualRenamesProperties", IsRequired = false, DefaultValue = true)]
    public Boolean ManualRenamesProperties { get { return (Boolean)base["manualRenamesProperties"]; } }

    [ConfigurationProperty("minifyCode", IsRequired = false, DefaultValue = true)]
    public Boolean MinifyCode { get { return (Boolean)base["minifyCode"]; } }

    [ConfigurationProperty("noAutoRenameList", IsRequired = false, DefaultValue = "")]
    public String NoAutoRenameList { get { return (String)base["noAutoRenameList"]; } }

    [ConfigurationProperty("outputMode", IsRequired = false, DefaultValue = "SingleLine")]
    public OutputMode OutputMode { get { return (OutputMode)base["outputMode"]; } }

    [ConfigurationProperty("preprocessorDefineList", IsRequired = false, DefaultValue = "")]
    public String PreprocessorDefineList { get { return (String)base["preprocessorDefineList"]; } }

    [ConfigurationProperty("preserveFunctionNames", IsRequired = false, DefaultValue = false)]
    public Boolean PreserveFunctionNames { get { return (Boolean)base["preserveFunctionNames"]; } }

    [ConfigurationProperty("preserveImportantComments", IsRequired = false, DefaultValue = true)]
    public Boolean PreserveImportantComments { get { return (Boolean)base["preserveImportantComments"]; } }

    [ConfigurationProperty("removeFunctionExpressionNames", IsRequired = false, DefaultValue = true)]
    public Boolean RemoveFunctionExpressionNames { get { return (Boolean)base["removeFunctionExpressionNames"]; } }

    [ConfigurationProperty("removeUnneededCode", IsRequired = false, DefaultValue = true)]
    public Boolean RemoveUnneededCode { get { return (Boolean)base["removeUnneededCode"]; } }

    [ConfigurationProperty("renamePairs", IsRequired = false, DefaultValue = "")]
    public String RenamePairs { get { return (String)base["renamePairs"]; } }

    [ConfigurationProperty("reorderScopeDeclarations", IsRequired = false, DefaultValue = true)]
    public Boolean ReorderScopeDeclarations { get { return (Boolean)base["reorderScopeDeclarations"]; } }

    [ConfigurationProperty("stripDebugStatements", IsRequired = false, DefaultValue = true)]
    public Boolean StripDebugStatements { get { return (Boolean)base["stripDebugStatements"]; } }
  }
}
